package learn.particleSys;

import java.util.ArrayList;

import processing.core.PApplet;
import processing.core.PVector;

public class ParticleSystem {
	ArrayList<Particle> particles;
	PApplet p;
	PVector initLocation;

	public ParticleSystem(PApplet parent, PVector initLocation) {
		p = parent;
		particles = new ArrayList<Particle>();
		this.initLocation = initLocation;
	}

	public void addParticle() {
		particles.add(new Particle(p, initLocation));
	}

	public void run() {
		for (int i = particles.size() - 1; i >= 0; --i) {
			Particle par = particles.get(i);
			par.run();
			if (par.isDead()) {
				particles.remove(i);
			}
		}
	}

}
